#hallo

'''alle 'print' wird von '#' aufgehalten'''

import matplotlib.pyplot as plt


class population:

    
    def __init__(self, initialpop, birthrate,deathrate,initialtime,finaltime,timestep):
        self.initialpop = initialpop 
        self.birthrate = birthrate
        self.deathrate = deathrate
        self.initialtime=initialtime
        self.finaltime=finaltime
        self.timestep=timestep
        self.time=[]
        self.poplist=[]
        self.birthlist=[]
        self.deathlist=[]
        

    def function(self,initialpop,birthrate,deathrate,initialtime,finaltime):
        
        x=0    
        

        while x==0:
            
            for t in range(initialtime,finaltime+1):                            #Das Modell wird rechnen
                if t<finaltime:
                    population=int(initialpop*((1+birthrate-deathrate)**t))
                    birth=int(population*birthrate)
                    death=int(population*deathrate)
                    
                    
                    t=t+1
                    x=0
                else:
                    x=1

                #print t,population,birth,death                                 #Hier kann die Daten wie Tabelle drucken werden.

                self.time.append(t)
                self.poplist.append(population)
                self.birthlist.append(birth)
                self.deathlist.append(death)

            
            #print self.time,self.poplist,self.birthlist,self.deathlist         #Hier kann jede list drucken werden.

    

            


    def diagramm(self):
    
        
        plt.plot([self.time],[self.poplist],'bo')               #Diagramm von Population
        plt.xlabel('Year')
        plt.ylabel ('Population')
        #plt.show()


        plt.plot([self.time],[self.birthlist],'go')             #Diagramm von Birth
        plt.xlabel('Year')
        plt.ylabel ('Birth')
        #plt.show()


        plt.plot([self.time],[self.deathlist],'rs')             #Diagramm von Death
        plt.xlabel('Year')
        plt.ylabel ('Death')
        #plt.show()
 
           

mein_objekt = population(20,0.2,0.1,0,100,1)     
mein_objekt.function(20,0.2,0.1,0,100)
mein_objekt.diagramm()
